﻿#include "MyShape.h"

class MyLine: public MyShape
{
private:
	char* _stroke;	
	float _strokeWidth;
	int _x1;
	int _y1;
	int _x2;
	int _y2;
public:
	//Default constructor
	MyLine() {
		
	}
	//Parameterized constructors
	MyLine(char stroke[], float strokeWidth, int x1, int y1, int x2, int y2) {
		_stroke = stroke;		
		_strokeWidth = strokeWidth;
		_x1 = x1;
		_y1 = y1;
		_x2 = x2;
		_y2 = y2;
	}	
	//Override methods
	void Draw() {
		this->GetMyGraphic()->DrawLine(_stroke, _strokeWidth, _x1, _y1, _x2, _y2);		
	}
	string ToString() {
		string s = "";
		s += "<line x1='";		
		s += MyFunction::IntToString(this->_x1);
		s += "' y1='";
		s += MyFunction::IntToString(this->_y1);
		s += "' x2='";
		s += MyFunction::IntToString(this->_x2);
		s += "' y2='";
		s += MyFunction::IntToString(this->_y2);
		s += "' stroke='rgb(";
		s += MyFunction::Char2String(this->_stroke[0]);
		s += ", ";
		s += MyFunction::Char2String(this->_stroke[1]);
		s += ", ";
		s += MyFunction::Char2String(this->_stroke[2]);
		s += ")' stroke-width='";
		s += MyFunction::FloatToString(this->_strokeWidth);
		s += "' />";

		return s;
	}

	void Move(int xdistance,int ydistance){
		this->_x1 += xdistance;
		this->_y1 += ydistance;
		this->_x2 += xdistance;
		this->_y2 += ydistance;
	}

	void SetColor(char* color);

	void SetEffect(MyEffect* effect){
		MyShape* shapeEffect = new MyLine(*this);
		effect->SetShape(shapeEffect);
		effect->DrawEffect();
	}

	//Destructor
	~MyLine() {
		//delete _stroke;		
	}
};